#include <string.h>
#include <stdlib.h>
#include "SceneNode.h"

int next_id=0;

SceneNode* SceneNode_FromValues( char* name, int child_count,
								 Vector3d* position, Quaternion* orientation )
{
	SceneNode* s = (SceneNode*) malloc(sizeof(SceneNode));
	strcpy( s->name, name );
	s->id = next_id++;
	s->position = *position;
	s->orientation = *orientation;
	s->children = 
		child_count>0 ? (SceneNode**) malloc( child_count * sizeof(SceneNode*)) : NULL;
	s->child_count = child_count;
	return s;
};

void SceneNode_destroy( SceneNode* r )
{
	int i;
	for( i=0 ; i<r->child_count ; ++i )
	{
		SceneNode_destroy( r->children[i] );
	}
	free(r->children);
	free(r);
}
